package paopaoteacher;

import java.util.Arrays;

/**
 * 本类用于冒泡排序
 *
 */
public class P03 {
    public static void main(String[] args) {
        int[]arr=new int[]{1,4,0,45,2,42,63,12,100,-1};
        //外层循环控制比较的轮数，轮数为数组元素个数
        for (int j = 1; j < arr.length; j++) {

            //内层循环控制比较的次数
            for (int i = 0; i < arr.length-j; i++) {
                if (arr[i]>arr[i+1]){
                    int temp=arr[i];
                    arr[i]=arr[i+1];
                    arr[i+1]=temp;
                }
            }
            System.out.println("第"+j+"轮:"+Arrays.toString(arr));
        }
        System.out.println("最终结果:"+Arrays.toString(arr));
    }
}
